Skip to content

Conversation

@andrewelamb
Copy link
Contributor

@andrewelamb andrewelamb commented Oct 23, 2025

Problem:

The new JSONSchema classes need documentation.
The old JSONSchema classes need to be deprecated.
While writing the tutorial a bug was found: JSONSchema.store-async was overwriting its id attribute with the id field from the CreateSchemaResponse . These are not the same thing. JSONSchema.id is an integer identifier created by synapse in string form (ie. 1880). The id from CreateSchemaResponse is a url.

Solution:

Documentation files added for new JSONSchema classes.

Old JSONSchema classes are deprecated. For these, I just deprecated the classes. The old file states This is a beta implementation and is subject to change. Use at your own risk. so i didn't include examples of how to use the new classes here. I can add these if needed.

Tutorials added in this PR

The bug was fixed in JSONSchema.store-async by not updating the id attribute.

@andrewelamb andrewelamb requested a review from a team as a code owner October 23, 2025 17:22
@andrewelamb andrewelamb marked this pull request as draft October 23, 2025 17:22
@andrewelamb andrewelamb marked this pull request as ready for review October 23, 2025 18:57
@jaymedina
Copy link
Contributor

There are broken reference links in the appendix:
image

* You have a working [installation](../installation.md) of the Synapse Python Client.
* Make sure that you have completed the [Project](./project.md) tutorial, which covers creating and managing projects in Synapse. This is a prerequisite because you need a project to organize and store the folder used in this tutorial.
* You are familiar with Synapse concepts: [Project](./project.md), [Folder](./folder.md), [File](./file.md).
* You are familiar with [adding annotations](./annotation.md) to synapse entity.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Would also add that familiarity with SchemaOrganization is also necessary

try:
schema.get()
except Exception as e:
schema.store(schema_body=schema_body, version=VERSION)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I ran the tutorial, I got an error:

Traceback (most recent call last):
  File "/Users/lpeng/code/synapsePythonClient/docs/tutorials/python/tutorial_scripts/json_schema.py", line 91, in <module>
    raise e
  File "/Users/lpeng/code/synapsePythonClient/docs/tutorials/python/tutorial_scripts/json_schema.py", line 84, in <module>
    schema.store(schema_body=updated_schema, version=VERSION)
  File "/Users/lpeng/code/synapsePythonClient/synapseclient/core/async_utils.py", line 69, in f
    return self.fn(obj, *args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lpeng/code/synapsePythonClient/synapseclient/core/async_utils.py", line 188, in newmethod
    return asyncio.run(wrapper(*args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lpeng/.pyenv/versions/3.12.6/lib/python3.12/asyncio/runners.py", line 194, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/Users/lpeng/.pyenv/versions/3.12.6/lib/python3.12/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lpeng/.pyenv/versions/3.12.6/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/lpeng/code/synapsePythonClient/synapseclient/core/async_utils.py", line 175, in wrapper
    return await getattr(self, async_method_name)(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lpeng/code/synapsePythonClient/synapseclient/models/schema_organization.py", line 947, in store_async
    completed_request: CreateSchemaRequest = await request.send_job_and_wait_async(
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lpeng/code/synapsePythonClient/synapseclient/models/mixins/asynchronous_job.py", line 123, in send_job_and_wait_async
    results = await send_job_and_wait_async(
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lpeng/code/synapsePythonClient/synapseclient/models/mixins/asynchronous_job.py", line 338, in send_job_and_wait_async
    **await get_job_async(
      ^^^^^^^^^^^^^^^^^^^^
  File "/Users/lpeng/code/synapsePythonClient/synapseclient/models/mixins/asynchronous_job.py", line 463, in get_job_async
    result = await client.rest_get_async(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lpeng/code/synapsePythonClient/synapseclient/client.py", line 8990, in rest_get_async
    response = await self._rest_call_async(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/lpeng/code/synapsePythonClient/synapseclient/client.py", line 8960, in _rest_call_async
    self._handle_httpx_synapse_http_error(response)
  File "/Users/lpeng/code/synapsePythonClient/synapseclient/client.py", line 8645, in _handle_httpx_synapse_http_error
    exceptions._raise_for_status_httpx(
  File "/Users/lpeng/code/synapsePythonClient/synapseclient/core/exceptions.py", line 296, in _raise_for_status_httpx
    raise SynapseHTTPError(message, response=response)
synapseclient.core.exceptions.SynapseHTTPError: 403 Client Error: You do not have CREATE permission for ORGANIZATION : 1255
/schema/type/create/async:   0%|                                                                                                              | 0.00/1.00 [00:01<?, ?it/s]

I think maybe it makes sense to have the schema already stored so that users can just get the schema?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll defer to the team, but throughout these tutorials, these resources will have already been created and it's up to the user to update the names as they run the script so there's no name clashes.

Although, I'm unsure how clear we explicitly make that in our tutorials.

Copy link
Contributor

@linglp linglp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the formatting is still off here:
Screenshot 2025-10-27 at 12 57 34 PM

Could you help fix it?

# TODO: Deprecate method in https://sagebionetworks.jira.com/browse/SYNPY-1583
@deprecated(
version="4.11.0",
reason="To be removed in 5.0.0.",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked other deprecation messages, and it seems that they usually mention which new methods should be used instead. It might be helpful to add that here as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only thing that this was supporting was the jsonschema services. So we could point to the jsonschema services in general, or just leave it as is.


# 2. Take a look at the constants and structure of the JSON schema
ORG_NAME = "myUniqueAlzheimersResearchOrgTutorial"
ORG_NAME = "myUniqueAlzheimersResearchOrgTutorialTest"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ORG_NAME = "myUniqueAlzheimersResearchOrgTutorialTest"
ORG_NAME = "myUniqueAlzheimersResearchOrgTutorial"


```python
{!docs/tutorials/python/tutorial_scripts/json_schema.py!lines=1-19}
{!docs/tutorials/python/tutorial_scripts/json_schema.py!lines=1-10}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewelamb please be sure to triple check these line references if there were changes made to that python script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants